package com.iyimo.core.mvc{
	import com.iyimo.core.i.IProxy;
	
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;
	import com.iyimo.event.Notification;
	
	public class Proxy extends EventDispatcher implements IProxy{
		private static var _listener:EventDispatcher;
		
		protected var _data:Object;
		
		public function Proxy(data:Object){
			_data = data;
		}

		public static function initialize(listener:EventDispatcher):void{
			if (_listener == null)
				_listener = listener;
		}
		
		public function get data():Object{
			return _data;
		}
		
		/**
		 * 派发notification,仿造puremvc,其实也是事件
		 */		
		protected function sendNotification(name:String, data:* = null):void{
			var n:Notification = new Notification(name);
			n.data = data;
			_listener.dispatchEvent(n);
		}
	}
}